package com.xian.cloud.controller;

import com.xian.cloud.api.UserDubboApi;
import com.xian.cloud.entity.User;
import com.xian.cloud.entity.UserEntity;
import com.xian.cloud.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xlr
 * @Date: Created in 10:23 PM 2019/8/23
 */
@Slf4j
@RestController
public class HelloController implements UserDubboApi {


    @Autowired
    private UserService userService;


    @Override
    public User info(String name) {
        User user = new User();
        user.setEmail( "aa" );
        user.setId( 1L );
        user.setUserName( name );
        log.info( "user:{}",user );
        return user;
    }

    @Override
    public String update(@RequestBody User user) {

        UserEntity userEntity = new UserEntity();
        BeanUtils.copyProperties(user,userEntity);
        boolean b = userService.updateTx(userEntity);
        return b + "";
    }
}
